Skip to content

fix(opencode-plugin): stop the v2 prompt hook from holding the send on recall - #5496

Open
oliver-mee wants to merge 2 commits into
volcengine:mainfrom
oliver-mee:ov-opencode-v2-nonblocking-recall
Open

oliver-mee wants to merge 2 commits into
volcengine:mainfrom
oliver-mee:ov-opencode-v2-nonblocking-recall

Conversation

@oliver-mee

@oliver-mee oliver-mee commented Sep 30, 2026 •

Copy link
Copy Markdown

Description

On OpenCode v2, a sent message can sit unsubmitted while OpenViking retrieves memories. OpenCode awaits the plugin's prompt hook before admitting the message. After #7582, the session-start and recall requests already run concurrently, but the hook still awaits both. Holding the recall response open on a clean OpenCode 2.3.0 install reproduces the delay.

This moves the wait to context, which runs immediately before the model request. The prompt hook starts both requests and returns. The message is admitted while recall is in flight. The model request still gets the context that arrives within the configured budget.

OpenCode rebuilds that model context on every request. The plugin records the injected text by message so a later request, including one after a restart, can use identical bytes and preserve the provider's prefix cache. Prior releases stored the same information in prompt metadata, which this path still reads.

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

Fixes #5148.
Part of #5494. Builds on the parallel fetches in #7582 and follows the replay approach from #4137.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • Route the v2 hook through lib/v2-recall.mjs. Start the recallWaitMs clock when the prompt hook starts, with a default of 5000 ms. Skip per-message recall that arrives after the budget and carry late session-start context to the next message.
  • Keep up to 500 injected messages per session in OpenCode plugin storage. Clean up on session deletion. recallLedger: false keeps replay state in memory.
  • Exercise delayed responses, restart replay, legacy prompt metadata and failure handling in tests/v2-recall.test.mjs.

Testing

On macOS with Node 24.21.0, the OpenCode plugin suite passed 67 tests on 314fe8d0e. The plugin syntax, shared sync and all seven version checks passed.

In a packed OpenCode 2.3.0 loopback test, the base 674e07f2a held the prompt while recall was blocked. This head admitted the message before the response was released, then included the returned text in the first model request. A second turn after restarting OpenCode replayed the first user message byte for byte. The fixture recorded just one fetch for the original query.

The broader shared suite hit a Desktop launcher assertion in install-tui.test.mjs that also fails on the pristine base. The runtime test used a local provider fixture.

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published (N/A, there are none)

Additional Notes

The model request keeps the remaining recall wait, so this is a prompt-admission improvement. The budget still controls how long slow retrieval can delay the first model token.


Developed with AI agents, with a human in the loop. Models: Claude Opus 5.5, GPT-6.1 Sol, and GPT-6.2 Sol.

@ZaynJarvis ZaynJarvis added the agent-plugins Agent harness and plugin integrations label Oct 1, 2026
@oliver-mee
oliver-mee force-pushed the ov-opencode-v2-nonblocking-recall branch 4 times, most recently from 4fc7a22 to 8168c7b Compare October 9, 2026 09:02
@oliver-mee
oliver-mee force-pushed the ov-opencode-v2-nonblocking-recall branch from 8168c7b to f8ccb6f Compare October 31, 2026 20:46
@oliver-mee

Copy link
Copy Markdown
Author

Refreshed on current main 012e1f0c8340 as f8ccb6fc2. I rebuilt the final patch on the new base rather than replaying the old intermediate commits. The prompt hook still returns without awaiting recall, and ledger replay, late context and restart coverage remain intact. On macOS / Node 24.22.2, all 63 OpenCode tests and the syntax/version gates pass. The shared suite is 620/621; the Desktop launcher output assertion also fails on pristine main. The PR body has the current validation scope. Upstream CI has not reported results yet.

Refresh assisted by GPT-6.1 Sol.

@oliver-mee
oliver-mee force-pushed the ov-opencode-v2-nonblocking-recall branch from ce66cad to 314fe8d Compare November 18, 2026 05:10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-plugins Agent harness and plugin integrations

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Bug]: user message display blocked 1.5–2.5s per send in opencode TUI — chat.message hook awaits remote recall serially

2 participants